package com.changgou.goods.dao;

import com.changgou.goods.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;

public interface BrandMapper extends Mapper<Brand> {
    @Select("SELECT * FROM tb_brand WHERE id IN (\n" +
            "SELECT brand_id FROM tb_category_brand WHERE category_id IN (\n" +
            "SELECT id FROM tb_category WHERE `name`=#{categoryName})\n" +
            ")")
    public List<Brand> findBrandByCategoryName(@Param("categoryName")String categoryName);

    @Select("SELECT `name`,`options` FROM tb_spec WHERE template_id = (\n" +
            "SELECT template_id FROM tb_category WHERE `name`=#{categoryName} LIMIT 1)\n" +
            "ORDER BY seq")
    public List<Map> findSpeecByCategoryName(@Param("categoryName")String categoryName);
}
